<?php require('connections/con_gl.php'); ?>

<?php

cekAkses($_SESSION[akses],"PD-3-2");

mysql_select_db($database_con_gl, $con_gl);

$query_klas = "SELECT id, kelompok FROM gl_kelompok";
if(!strstr($_SESSION[akses],'A-1-4')) {
	//$query_klas .= " where gudang='$_SESSION[lokasi]'";	
}
$query_klas .= " ORDER BY kelompok ASC"; //echo $query_klas;

$klas = mysql_query($query_klas, $con_gl) or die(mysql_error());

$row_klas = mysql_fetch_assoc($klas);

$totalRows_klas = mysql_num_rows($klas);



$colname_edit = "-1";

if (isset($_GET['id'])) {

  $colname_edit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);

}

mysql_select_db($database_con_gl, $con_gl);

$query_edit = sprintf("SELECT * FROM gl_barang WHERE id = %s", $colname_edit);

$edit = mysql_query($query_edit, $con_gl) or die(mysql_error());

$row_edit = mysql_fetch_assoc($edit);

$totalRows_edit = mysql_num_rows($edit);

?>

<link type="text/css" rel="stylesheet" href="css/jquery.wysiwyg.css" />

<script type="text/javascript" src="js/jquery.wysiwyg.js"></script>

<script type="text/javascript">

$(document).ready(function() {



	$().ajaxStart(function() {

		$('#loading').show();

		$('#result').hide();

	}).ajaxStop(function() {

		$('#loading').hide();

		$('#result').fadeIn('slow');

	});



	$('#edit').submit(function() {

		$.ajax({

			type: 'POST',

			url: $(this).attr('action'),

			data: $(this).serialize(),

			success: function(data) {

				$('#result').html(data);

			}

		})

		return false;

	});

  $('#result').click(function(){

  $(this).hide();

  });

})

$(function()

  {

	  $('#keterangan').wysiwyg();

  });

</script>
<script>
function sendRespondKelompok() {
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('divKelompok');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
		if (ajaxRequest.readyState == 3) {
			var ajaxDisplay = document.getElementById('divKelompok');
			ajaxDisplay.innerHTML = "<img src='images/ajax-loader.gif' />";
		}
	}
	ajaxRequest.open("GET", "include/send_respondkelompok.php", true);
	ajaxRequest.send(null);	
}
</script>

<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>

<div id="result" style="display:none;"></div>

<h1>Edit Barang/Jasa</h1>

<form action="proses/barang.php?act=edit" method="POST" name="edit" id="edit" >

  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">

    <tr>

      <td width="17%" align="right" bgcolor="#FFFFFF">Kelompok*  : </td>

      <td colspan="3" bgcolor="#FFFFFF"><label id='divKelompok'>

        <select name="kelompok" id="kelompok">

          <?php

do {  

?>

          <option value="<?php echo $row_klas['id']?>"<?php if (!(strcmp($row_klas['id'], $row_edit['kelompok']))) {echo "selected=\"selected\"";} ?>><?php echo $row_klas['kelompok']?></option>

          <?php

} while ($row_klas = mysql_fetch_assoc($klas));

  $rows = mysql_num_rows($klas);

  if($rows > 0) {

      mysql_data_seek($klas, 0);

	  $row_klas = mysql_fetch_assoc($klas);

  }

?>
        </select>

      </label><?php if(strstr($_SESSION['akses'],"JS-7-1")) { ?><a href="index.php?component=kelompokbarang&task=add&open=window" onclick="NewWindow(this.href,'name','825','450','yes');return false"><img src="images/add_.png" hspace="2" border="0" /></a><?php } ?></td>
    </tr>

    <tr valign="top">

      <td align="right" bgcolor="#FFFFFF">Barang/Jasa* : </td>

      <td width="28%" bgcolor="#FFFFFF">

        <input name="barang" type="text" id="barang" value="<?php echo $row_edit['barang']; ?>" size="30" maxlength="100" />

        <input <?php if (!(strcmp($row_edit['paket'],1))) {echo "checked=\"checked\"";} ?> name="ada" type="checkbox" id="ada" value="1" onclick="javascript: if(this.checked==true){$('#masasewa').show(1000);$('#jam').focus();}else{$('#masasewa').hide(1000);$('#jam').blur();}" />
        Paket Sewa Jam 
      </td>
      <td width="13%" bgcolor="#FFFFFF">
	  <?php if($row_edit['paket']==1){ ?>
	  <label id="masasewa">
	  Masa Sewa : 
      <input name="jam" type="text" id="jam" value="<?php echo $row_edit['jam']; ?>" size="5" maxlength="5" /> 
      Jam 
	  </label>
	  <?php }else{ ?>
	  <label id="masasewa" style="display:none;">
	  Masa Sewa : 
      <input name="jam" type="text" id="jam" value="" size="5" maxlength="5" /> 
      Jam 
	  </label>
	  <?php } ?>
	  </td>
      <td width="42%" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>

    <tr valign="top">

      <td align="right" bgcolor="#FFFFFF">Keterangan : </td>

      <td colspan="3" bgcolor="#FFFFFF"><label>

        <textarea name="keterangan" cols="85" rows="5" id="keterangan"><?php echo $row_edit['keterangan']; ?></textarea>

        <input name="id" type="hidden" id="id" value="<?php echo $row_edit['id']; ?>" />

      </label></td>
    </tr>

    <tr>

      <td align="left" bgcolor="#FFFFFF"><em>*Harus diisi</em></td>

      <td colspan="3" bgcolor="#FFFFFF"><label>

        <input name="Save" type="submit" id="Save" value="Simpan" />

        </label>

          <label>

          <input type="button" name="Button" value="Batal" onClick="javascript:history.go(-1);">
        </label></td>
    </tr>
  </table>

</form>

